include( 'shared.lua' )
include( 'cl_hud.lua' )
include( 'cl_menu.lua' )
include( 'cl_mainmenu.lua' )
include( 'cl_base_scoreboard.lua' )
include( 'cl_perks.lua' )
include( 'cl_loadout.lua' )
include( 'cl_render.lua' )

function XPWorld(ply, com, args)
	ply:SetNWInt("Draw",1)
	ply:SetNWInt("Height",1)
	timer.Create("drawXXP",3,0,function() ply:SetNWInt("Draw",0) ply:SetNWInt("Height",0) end)
end

concommand.Add("dm_xp", XPWorld)

function DrawXP()
	function GetStruc(pos)
		local struc = {}
		struc.pos = {}
		struc.pos[1] = pos.x -- x pos
		struc.pos[2] = pos.y -- y pos
		struc.color = Color(255,0,0,255) -- Red
		struc.text = LocalPlayer():GetNWInt("lastxp").." XP" -- Text
		struc.font = "ScoreboardText" -- Font
		struc.xalign = TEXT_ALIGN_CENTER -- Horizontal Alignment
		struc.yalign = TEXT_ALIGN_CENTER -- Vertical Alignment
		return struc
	end
	if LocalPlayer():GetNWInt("Draw") == 1 then
		LocalPlayer():SetNWInt("Height",LocalPlayer():GetNWInt("Height")+0.1)
		local SPos = (LocalPlayer():GetNetworkedVector( "lastkill" ) + Vector(math.sin(LocalPlayer():GetNWInt("Height")/3)*5, math.sin(LocalPlayer():GetNWInt("Height")/3)*5, LocalPlayer():GetNWInt("Height"))):ToScreen()
		draw.Text(GetStruc(SPos))
	end
end
hook.Add("HUDPaint","Draw XP",DrawXP)

function GM:ShotFired(ply,hit)
	print("DM: Shot fired by "..ply:Nick().." with spread "..hit[1]..", "..hit[2]..", "..hit[3].."!")
end

concommand.Add("dm_killcam", function(ply, cmd, args)
	LocalPlayer().KillCam = player.GetByID(args[1])
end)

hook.Add("Think", "killcam", function()
	if !LocalPlayer():Alive() and LocalPlayer().KillCam and LocalPlayer().KillCam:IsValid() and LocalPlayer().KillCam:IsPlayer() then
		local Vec1 = LocalPlayer().KillCam:GetPos() + Vector(0,0,50)
		local Vec2 = LocalPlayer():GetShootPos() -- This is where we are
		local Ang = (Vec1 - Vec2):Angle() -- Gets the angle between the two points
		LocalPlayer():SetEyeAngles( Ang )
	elseif !LocalPlayer():Alive() then
		LocalPlayer().KillCam = nil
	end
end)
